package io.renren.modules.project.controller;

import java.util.List;
import java.util.Map;

import io.renren.common.annotation.SysLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.project.entity.ProjectApplicantInfoEntity;
import io.renren.modules.project.service.ProjectApplicantInfoService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.common.utils.R;




/**
 * 
 * 
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2018-11-06 09:46:27
 */
@RestController
@RequestMapping("/generator/projectapplicantinfo")
public class ProjectApplicantInfoController {
	@Autowired
	private ProjectApplicantInfoService projectApplicantInfoService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("generator:projectapplicantinfo:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<ProjectApplicantInfoEntity> projectApplicantInfoList = projectApplicantInfoService.queryList(query);
		int total = projectApplicantInfoService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(projectApplicantInfoList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}

	/**
	 * 所有申请方列表
	 */
	@RequestMapping("/alllist")
	@RequiresPermissions("generator:projectapplicantinfo:alllist")
	public R queryAll(){
		List<ProjectApplicantInfoEntity> projectApplicantInfoList = projectApplicantInfoService.queryAll();

		return R.ok().put("applicantList", projectApplicantInfoList);
	}

	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("generator:projectapplicantinfo:info")
	public R info(@PathVariable("id") String id){
		ProjectApplicantInfoEntity projectApplicantInfo = projectApplicantInfoService.queryObject(id);
		
		return R.ok().put("projectApplicantInfo", projectApplicantInfo);
	}
	
	/**
	 * 保存
	 */
	@SysLog("新建项目申请方")
	@RequestMapping("/save")
	@RequiresPermissions("generator:projectapplicantinfo:save")
	public R save(@RequestBody ProjectApplicantInfoEntity projectApplicantInfo){
		projectApplicantInfoService.save(projectApplicantInfo);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@SysLog("修改项目申请方")
	@RequestMapping("/update")
	@RequiresPermissions("generator:projectapplicantinfo:update")
	public R update(@RequestBody ProjectApplicantInfoEntity projectApplicantInfo){
		projectApplicantInfoService.update(projectApplicantInfo);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("generator:projectapplicantinfo:delete")
	public R delete(@RequestBody String[] ids){
		projectApplicantInfoService.deleteBatch(ids);
		
		return R.ok();
	}
	
}
